"""
24ms 3088KB 38Min
进制转换问题，注意火星数字进位后，低位没有零，当个位数为0时不显示，只有当十位个位都为0时显示tret。
"""


low=['','jan', 'feb', 'mar', 'apr', 'may', 'jun',\
        'jly', 'aug', 'sep', 'oct', 'nov', 'dec']
high=['','tam', 'hel', 'maa', 'huh', 'tou', 'kes', \
            'hei', 'elo', 'syy', 'lok', 'mer', 'jou']

num=int(input())

for row in range(num):
    lget=input()
    try:
    # if lget.isdigit():
        tempint=int(lget)
        if tempint==0:
            print('tret')
            continue

        highnum,lownum=divmod(tempint,13)
        if highnum==0 or lownum==0:
            ans=high[highnum]+low[lownum]
        else:
            ans=high[highnum]+' '+low[lownum]
        print(ans)
    # elif lget.isalpha():
    except:
    # else:
        ans=0
        marsnum=lget.split()
        for j in marsnum:
            if j in low:
                ans+=low.index(j)
            elif j in high:
                ans+=high.index(j)*13
        print(ans)
        
